class Game:
    conner = ['x', 'x', 'x', 'x', 'x']
    map = """
         {0}
       /   \\
      {4}     {1}
      \     / 
       {3}——{2}
    """

    def draw_map(self):
        print(self.map.format(self.conner[0], self.conner[1], self.conner[2], self.conner[3], self.conner[4]))

    def start(self):
        print("游戏开始")
        print("规则:'x'为熄灭状态,'o'为点亮状态被点亮的角,其对面的两角状态会反转",
              "获胜条件:五个角均为点亮状态")

        while True:
            self.draw_map()
            if self.is_win():
                print("您获得了胜利")
                break
            print("请输入数字 1到5:\n")
            i = input()
            if i == "q":
                break

            self.reverse(int(i))
        print("游戏结束")

    def reverse(self, i: int):
        i -= 1
        if self.conner[int(i)] == 'o':
            print("非法的输入")
            return
        for k in (i, (i + 2) % 5, (i + 3) % 5):

            if self.conner[k] == 'x':
                self.conner[k] = 'o'
            else:
                self.conner[k] = 'x'

    def is_win(self):
        if 'x' in self.conner:
            return False
        return True


if __name__ == '__main__':
    Game().start()
